package cserver.hsk.la.data;

public class Message {

	private String msgText = "";

	private String dateTime = "";

	/**
	 * TYPE类型，1一般消息，在列表中获得时不会被删除，删除由DELETE 2，被get后即刻删除，不需要DELETE命令
	 */
	private String token = "";

	private int type = 0;

	public Message(String msgText, String dateTime, String token, int type) {
		this.msgText = msgText;
		this.dateTime = dateTime;
		this.token = token;
		this.type = type;
	}

	public Message(String info) {
		String[] splt = info.split("@.");
		this.msgText = splt[0];
		this.dateTime = splt[1];
		this.token = splt[2];
		this.type = Integer.valueOf(splt[3]);
	}

	public String getText() {
		return msgText;
	}

	public String getDateTime() {
		return dateTime;
	}

	public String getToken() {
		return token;
	}

	public int getType() {
		return type;
	}
	
	public boolean equals(Message msg)
	{
		boolean result=false;
		
		if(this.dateTime.trim().contains(msg.dateTime.trim())&&this.msgText.trim().contains(msg.msgText.trim())
				&&this.token.trim().contains(msg.token.trim())&&this.type==msg.type)
			return true;
		
		return result;
	}
	
	public String getString()
	{
		String result="";
		
		result+=this.msgText+"@.&"+this.dateTime+"@.&"+this.token+"@.&"+this.type;
		
		return result;
	}

}
